package com.zh.push.util;

import com.alibaba.fastjson.JSONObject;
import com.zh.common.websocket.ThmsWebSocketHandler;
import com.zh.common.websocket.ThmsWebSocketMessage;
import com.zh.device.po.DeviceRela;

import java.util.List;

/**
 * webSocket push
 */
public class WebSocketPush {

    /**
     * GPS 推送
     * @param jsonObject
     * @param deviceRelas
     */
    public static void gspPush(JSONObject jsonObject,List<DeviceRela> deviceRelas) {
        //获取websocket
        ThmsWebSocketHandler swsh = ThmsWebSocketHandler.getSystemWebSocketHandler();
        ThmsWebSocketMessage twsm;
        //发送的消息
        try{
              for (DeviceRela deviceRela:deviceRelas){
                  twsm= new ThmsWebSocketMessage("gps", deviceRela.getDeviceBindingId(),"gps"+ deviceRela.getDeviceBindingId(), jsonObject);
                  swsh.sendMessageToUsers(twsm);
              }
        }catch (Exception e){
                e.printStackTrace();
        }

    }
}
